﻿using System;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Threading.Tasks;
using Codeflows;

namespace CodeflowsHost
{
    [ServiceContract]
    public interface ICodeflowWorker
    {
        [WebGet(UriTemplate = "/dispatch/{codeflowId}")]
        void Dispatch(string codeflowId);
    }

    public class CodeflowWorker : ICodeflowWorker
    {
         public void Dispatch(string codeflowId)
         {             
             Task.Factory.StartNew(() => CodeflowApplication.Run(Guid.Parse(codeflowId)));
         }
    }
}